package com.sh.cloudrender.application.config;

import com.sh.cloudrender.domian.service.kube.NamespaceService;
import com.sh.cloudrender.domian.service.kube.NodeService;
import com.sh.cloudrender.domian.service.kube.TraefikService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class EngineBootConfig implements ApplicationRunner {

    @Value("${engine.namespace}")
    private String namespace;
    @Autowired
    private NamespaceService ns;
    @Autowired
    private TraefikService traefikService;
    @Autowired
    private NodeService nodeService;


    @Override
    public void run(ApplicationArguments args) {
        ns.initNamespace(namespace);
        traefikService.createMiddlewareFromYamlResource(namespace, "/kube_template/middleware.yaml");
        nodeService.labelNodesWithGPU();
    }
}
